<?php $frmSubject = $this->frmSubject;
$user_type = $this->user_type;
$cancel_url = $this->url(array('module'=>'faculty','controller'=>'index','action'=>''));
?>
<style>
dt{ display: none;}
</style>
<div class="row">
	<div class="col-lg-12">
		<div class="box" style="width: 95%; margin: 0 auto;">
			<header class="dark">
				<div class="icons"><i class="icon-ok"></i></div>
					<h5>បន្ថែមមហាវិទ្យាល័យ/Add More Faculty</h5>
                    <div class="toolbar">
                    	<ul class="nav">
							<li>
                            <div class="btn-group" style="padding: 10px;">
                            	<a class="accordion-toggle btn btn-xs minimize-box" data-toggle="collapse" href="#collapse2">
                                	<i class="icon-chevron-up"></i>
                                </a>
                                <button class="btn btn-xs btn-primary close-box"><i class="icon-group"></i></button>
                            </div>
                            </li>
                     	</ul>
                	</div>
          	</header>
			<div id="collapse2" class="body collapse in">
				<form class="form-horizontal" id="popup-validation" enctype="multipart/form-data" method="post">
                    <div style="float: left; text-align: left;" class="control-label col-lg-9">
	               		<div class="form-group">
	                    	<label class="control-label col-lg-4"> មុខវិជ្ជា / Subject : </label>
	                        <div class="col-lg-6">
	                        	<?php echo $frmSubject->getElement('subject');?>
	                        </div>
	               		</div>
	               		<div class="form-group">
	                    	<label class="control-label col-lg-4"> ពិពណ៌នា / Description : </label>
	                        <div class="col-lg-6">
	                        	<?php echo $frmSubject->getElement('description');?>
	                        </div>
	               		</div>
	               		<div class="form-group">
	                    	<label class="control-label col-lg-4"> ស្ថានភាព / Status : </label>
	                        <div class="col-lg-6">
	                        	<?php echo $frmSubject->getElement('status');?>
	                        </div>
	               		</div>
	               		<div class="form-group">
               			<?php if($user_type==1){
                    		echo "<div class='form-group'>
			                    	<label class='control-label col-lg-4'> សាខា / Branch : </label>
			                        <div class='col-lg-6'>";
                    			echo $frmSubject->getElement('branch');
                    		echo "</div>
	               					</div>";
                    	}?>
               		</div>
               		</div>
               		
                    <div class="col-lg-5">
                        <div class="form-group">
                            <div class="input-group">
                                <input id="box1Filter" type="text" placeholder="Filter" class="form-control" />
                                <span class="input-group-btn">
                                    <button id="box1Clear" class="btn btn-warning" type="button">x</button>
                                </span>
                            </div>
                        </div>
                        <div class="form-group">
	                        	<?php echo $frmSubject->getElement('department');?>
                            <hr>
                            <div class="alert alert-block">
                                <span id="box1Counter" class="countLabel"></span>
                                <select id="box1Storage" class="form-control"></select>
                            </div>
                        </div>
                    </div>

                    <div class="col-lg-2">
                        <div class="btn-group btn-group-vertical" style="white-space: normal;">
                            <button id="to2" type="button" class="btn btn-primary">
                                <i class="icon-chevron-right"></i>
                            </button>
                            <button id="allTo2" type="button" class="btn btn-primary">
                                <i class="icon-forward"></i>
                            </button>
                            <button id="allTo1" type="button" class="btn btn-danger">
                                <i class="icon-backward"></i>
                            </button>
                            <button id="to1" type="button" class="btn btn-danger">
                                <i class=" icon-chevron-left icon-white"></i>
                            </button>
                        </div>
                    </div>

                    <div class="col-lg-5">
                        <div class="form-group">
                            <div class="input-group">
                                <input id="box2Filter" type="text" placeholder="Filter" class="form-control" />
                                <span class="input-group-btn">
                                    <button id="box2Clear" class="btn btn-warning" type="button">x</button>
                                </span>
                            </div>
                        </div>
                        <div class="form-group">
                        	<?php echo $frmSubject->getElement('department_select');?>
							<select id="box2View" multiple="multiple" class="form-control" size="8"></select>
                        </div>
                        <hr />

                        <div class="alert alert-block">
                            <span id="box2Counter" class="countLabel"></span>
                            <select id="box2Storage" name="branch_select" class="form-control"> </select>
                        </div>
                    </div>
                    <div class="form-group">
	                    	<label class="control-label col-lg-4">  </label>
	                        <div class="col-lg-4">
	                        	<button type="submit" id="save" name="save" class="btn btn-primary btn-grad"><i class="icon-save"> </i> រក្សាទុក</button>
	                        	<button type="submit" id="save_close" name="save_close" class="btn btn-primary btn-grad"><i class="icon-save"> </i> រក្សាទុក​​ និង​ ចាកចេញ</button>                        		
	                        	<a href="<?php echo $cancel_url; ?>"><button​ type="button" class="btn btn-primary btn-grad"><i class="icon-remove-sign"> </i> ចាកចេញ</button></a>
	                        </div>
	               	</div>
           	 	</form>
           	</div>
		</div>
	</div>
</div>
<script>
<?php $getfac =  $this->url(array('module'=>'subjects','controller'=>'index','action'=>'get-department-by-branch-id')); ?>
function getDepartment(){
	branch_id = $('#branch').val();
	$.ajax({
		url:"<?php echo $getfac;?>",
		type:"post",
		data:{'branch_id':branch_id},
		success: function(data){
			rs = $.parseJSON(data);
			//alert(rs);			
				if(rs!=""){
					//alert(data);	
					 $('#box1View').empty();
// 					 $('#box1View').val('').trigger("liszt:updated");
// 					 $('#box1View').append($("<option></option>").attr("value","").text("Please Select Faculty"));
					 for (var index = 1; index <= rs.length; index++) {
						$('#box1View').append($("<option></option>").attr("value",rs[index-1]['department_id']).text(rs[index-1]['department_name'])); 
					 }               
// 					$('#box1View').val('').trigger("liszt:updated");
				}else{
					$('#box1View').empty();
// 					 $('#box1View').val('').trigger("liszt:updated");
					 $('#box1View').append($("<option></option>").attr("value","").text("No Faculty Availabl!!"));
// 					$('#box1View').val('').trigger("liszt:updated");
				}
				$("#box1View").multiselect('refresh');	 
		},
		error:function(e){
			alert(e);
		}
	});
}
</script>